import QueryFilter from '@/components/QueryFilter';
import Toolbar from '@/components/Toolbar';
import useAntdList from '@/hooks/useAntdList';
import { queryAccount } from '@/service/globalSetting';
import { Button, Card, Form, Space, Table } from 'antd';
import { ColumnsType } from 'antd/lib/table';
import React from 'react';
import SaveModal from './SaveModal';
import useAntdModal from '@/hooks/useAntdModal';
import { queryI18nApp } from '@/service/deliver';
import { useNavigate } from 'react-router-dom';
const App = () => {
  let [form] = Form.useForm()
  const nav = useNavigate()
  const saveModal = useAntdModal();
  const { tableProps,tabsProps, search } = useAntdList(queryI18nApp, { form });
  const columns: ColumnsType<any> = [{
    title: '系统名称',
    dataIndex: 'name'
  },{
    title: '创建时间',
    dataIndex: 'createdAt'
  }, {
    title: '更新时间',
    dataIndex: 'updatedAt'
  },  {
    title: '操作',
    render(v) {
      return <Space>
        <Button onClick={()=>nav(`/workbench/deliver/i18n/detail?id=${v.id}`)} type="link">详情</Button>
        <Button onClick={()=>saveModal.openModal({...v},{title:'编辑系统'})} type="link">编辑</Button>
      </Space>
    }
  }
  ]
  return (<Card>
    <SaveModal {...saveModal}/>
    <QueryFilter

      items={[{
        label: '名称'
      }]} form={form} reset={search.reset} submit={search.submit} />
      <Toolbar
      rightRender={
        <Button onClick={()=>saveModal.openModal({},{title:'新增系统'})}>新增系统</Button>
      }
      />
    <Table columns={columns}  {...tableProps} />
  </Card>)
}
export default App